package com.quiputechnology.nexwm.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;

import com.quiputechnology.nexwm.model.Usuario;

public class LoggingAroundAspect {
	private final Logger logger = Logger.getLogger(LoggingAroundAspect.class);

	public Object around(ProceedingJoinPoint pjp) throws Throwable {
		logger.debug("around before");
		Object ret = null;
		try {
			Object[] args = pjp.getArgs();
			String username = (String) args[0];
			logger.debug(username);
			ret = pjp.proceed(args);
			Usuario usuario = (Usuario) ret;
			logger.debug(usuario.getNombre());
			logger.debug("around after-returning");
		} catch (Exception e) {
			logger.debug("around after-throwing");
			throw e;
		} finally {
			logger.debug("around after");
		}
		return ret;
	}
}
